using UnityEngine;
using QFramework;
using ProjectSurvivor;

namespace QFrameworkSurvivor
{
	public partial class Bomb : PowerUp
    {
        protected override Collider2D Collider2D => SelfCollider2D;

        public static void CreatExecute()
        {
            foreach (var enemyObj in GameObject.FindGameObjectsWithTag("Enemy"))
            {
                var enemy = enemyObj.GetComponent<Enemy>();
                if (enemy && enemy.gameObject.activeSelf)
                {
                    enemy.Hurt(Global.BombDamage.Value);
                }
            }
            AudioKit.PlaySound("Bomb");
            CameraController.Shake();
            UIGamePanel.FlashScreen.Trigger();
        }

        protected override void Execute()
        {
            CreatExecute();
            this.DestroyGameObjGracefully();
        }

        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.GetComponent<CollectableArea>())
            {
                FlyingToPlayer = true;
            }
        }
    }
}
